package dut.ir.lxb.weibo.util;

import java.io.FileInputStream;
import java.io.FileNotFoundException;

public class IOUtility
{
	@SuppressWarnings("resource")
	public static String loadTextFile(String fileName, String encoding)
	{
		if(encoding == null || encoding.trim().length() == 0)
			encoding = "utf-8";
		String code = "";
		FileInputStream fin;
		try
		{
			fin = new FileInputStream(fileName);
			int len = fin.available();
			byte[] bytes = new byte[len];
			fin.read(bytes);
			code = new String(bytes, encoding);
			return code;

		} catch (FileNotFoundException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
		return code;
		
	}
}
